//
//  LoginViewController.m
//  myfirstapp
//
//  Created by iGxnon on 2021/12/2.
//

#import "LoginViewController.h"

@interface LoginViewController ()

@property (nonatomic, strong) UIButton *btn;

@property (nonatomic, strong) UILabel *lable;

@property (nonatomic, strong) UILabel *subTitle;

@property (nonatomic, strong) UILabel *subDesc;

@property (nonatomic, strong) UIImageView *inputIdImg;

@property (nonatomic, strong) UIImageView *inputPwdImg;

@property (nonatomic, strong) UITextField *idText;

@property (nonatomic, strong) UITextField *pwdText;

@property (nonatomic, strong) UILabel *forgetPwd;

@property (nonatomic, strong) UIButton *roundBtn;

@property (nonatomic, strong) UILabel *licence;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.lable = [[UILabel alloc] initWithFrame:CGRectMake(15, 100, 68, 48)];
    self.lable.text = @"登录";
    self.lable.font = [UIFont boldSystemFontOfSize:35];
    self.lable.textColor = [UIColor colorWithRed:0.08 green:0.19 blue:0.35 alpha:1.0];
    self.lable.lineBreakMode = NSLineBreakByCharWrapping;
    
    self.subTitle = [[UILabel alloc] initWithFrame:CGRectMake(15, 149, 216, 25.5)];
    self.subTitle.text = @"您好，欢迎来到掌上重邮！";
    self.subTitle.font = [UIFont boldSystemFontOfSize:18];
    self.subTitle.lineBreakMode = NSLineBreakByCharWrapping;
    self.subTitle.textColor = [UIColor colorWithRed:0.43 green:0.47 blue:0.62 alpha:0.90];
    
    self.btn = [[UIButton alloc] initWithFrame:CGRectMake(30, 387, 315, 52)];
    [self.btn setTitle:@"登录" forState:UIControlStateNormal];
    self.btn.layer.cornerRadius = 25;
    self.btn.backgroundColor = [UIColor colorWithRed:0.29 green:0.27 blue:0.89 alpha:1.0];
    
    self.inputIdImg = [[UIImageView alloc] initWithFrame:CGRectMake(20, 208.5, 20, 20)];
    self.inputIdImg.image = [UIImage imageNamed:@"账号"];
    
    self.inputPwdImg = [[UIImageView alloc] initWithFrame:CGRectMake(20, 273.5, 20, 20)];
    self.inputPwdImg.image = [UIImage imageNamed:@"密码"];
    
    self.idText = [[UITextField alloc] initWithFrame:CGRectMake(60, 200, 247, 40)];
    self.idText.placeholder = @"请输入学号";
    self.idText.textColor = [UIColor colorWithRed:0.75 green:0.76 blue:0.77 alpha:1.0];
    self.idText.textAlignment = NSTextAlignmentLeft;
    self.idText.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    self.pwdText = [[UITextField alloc] initWithFrame:CGRectMake(60, 265, 247, 40)];
    self.pwdText.placeholder = @"身份证/统一认证码后六位";
    self.pwdText.textColor = [UIColor colorWithRed:0.75 green:0.76 blue:0.77 alpha:1.0];
    self.pwdText.textAlignment = NSTextAlignmentLeft;
    self.pwdText.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.pwdText.secureTextEntry = YES;
    
    self.subDesc = [[UILabel alloc] initWithFrame:CGRectMake(20, 328.5, 330, 33.5)];
    self.subDesc.text = @"2020级以后学生登录密码为统一认证码后六位，其余同学密码为身份证后六位。";
    self.subDesc.numberOfLines = 2;
    self.subDesc.font = [UIFont systemFontOfSize:14];
    self.subDesc.textColor = [UIColor colorWithRed:0.75 green:0.76 blue:0.77 alpha:0.7];
    
    self.forgetPwd = [[UILabel alloc] initWithFrame:CGRectMake(153, 498, 113, 26)];
    self.forgetPwd.text = @"忘记密码？";
    self.forgetPwd.font = [UIFont systemFontOfSize:14];
    self.forgetPwd.textColor = [UIColor colorWithRed:0.43 green:0.47 blue:0.62 alpha:0.50];
    
    self.roundBtn = [[UIButton alloc] initWithFrame:CGRectMake(114, 532, 16, 16)];
    self.roundBtn.layer.cornerRadius = self.roundBtn.frame.size.width/2;
    self.roundBtn.clipsToBounds = YES;
    
    self.roundBtn.layer.masksToBounds = NO;
    self.roundBtn.layer.borderWidth = 1;
    self.roundBtn.layer.borderColor = [UIColor colorWithRed:0.29 green:0.27 blue:0.89 alpha:1.0].CGColor;
    
    // clearColor or this
    self.roundBtn.backgroundColor = [UIColor clearColor];
    [self.roundBtn addTarget:self action:@selector(licenceClick:) forControlEvents:UIControlEventTouchUpInside];
    
    self.licence = [[UILabel alloc] initWithFrame:CGRectMake(143, 519, 200, 40)];
    self.licence.text = @"同意《掌上重邮用户协议》";
    self.licence.font = [UIFont systemFontOfSize:12];
    self.licence.textColor = [UIColor colorWithRed:0.43 green:0.47 blue:0.62 alpha:0.50];
    
    [self.view setBackgroundColor:[UIColor whiteColor]];
    
    [self.view addSubview:self.btn];
    [self.view addSubview:self.lable];
    [self.view addSubview:self.subTitle];
    [self.view addSubview:self.inputIdImg];
    [self.view addSubview:self.inputPwdImg];
    [self.view addSubview:self.idText];
    [self.view addSubview:self.pwdText];
    [self.view addSubview:self.subDesc];
    [self.view addSubview:self.forgetPwd];
    [self.view addSubview:self.roundBtn];
    [self.view addSubview:self.licence];
}

- (void) licenceClick: (UIButton *) btn {
    if (btn.isSelected) {
        btn.backgroundColor = [UIColor clearColor];
        btn.selected = false;
    }else {
        btn.backgroundColor = [UIColor colorWithRed:0.29 green:0.27 blue:0.89 alpha:1.0];
        btn.selected = true;
    }
}

@end
